﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Code.Models;
using Code.Commen;

namespace Code.BLL
{
    public class SystemManage:ManageBase<Option>
    {
        public int Edit(params Option[] ops)
        {
            var ups = base.GetTable<Option>().Where(p => ops.Select(p1 => p1.Key).Contains(p.Key)).Select(p=>p.Key).ToArray();
            int rs = 0;
            base.BeginTransaction();
            base.Insert<Option>(ops.Where(p => !ups.Contains(p.Key)).Select(p => new { p.Key, p.Value }).ToArray());
            base.Update<Option>(ops.Where(p => ups.Contains(p.Key)).ToNameValue(p => new { p.Value } as object, p => new { p.Key } as object));
            rs = base.ExecuteTransaction();
            return rs;
        }
    }
}
